package com.yuanian.timingwheel.test;

import com.yuanian.timingwheel.annotation.TimingTask;
import com.yuanian.timingwheel.annotation.TimingTaskType;
import com.yuanian.timingwheel.model.task.build.TaskExecutionBuilder;
import org.springframework.stereotype.Component;

import java.util.Date;

@Component
public class PurService {

    //TimingTaskType.AUTO为项目启动自动加入
    @TimingTask(dynamicParamSolver = "dynamicSolver", timingTaskType = TimingTaskType.AUTO)
    public void dayHandler() {

    }

    public TaskExecutionBuilder dynamicSolver() {
        return new TaskExecutionBuilder() {

            @Override
            //执行间隔时间，秒
            public long executionInterval() {
                return 1;
            }

            @Override
            //执行无限次
            public long executionRounds() {
                return Long.MAX_VALUE;
            }

            @Override
            //30秒后执行
            public Date executionTime() {
                return new Date(new Date().getTime() + 1000 * 30);
            }

            @Override
            public long executedRounds() {
                return 0;
            }

            @Override
            public String taskDesc() {
                return "test";
            }

            @Override
            public String businessId() {
                return "test01";
            }
        };
    }

}
